<ui:composition template="/dynamic/layout/layout.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

	<ui:define name="content">
		<style>
p label {
	width: 120px;
	float: left;
	text-align: right;
	height: 30px;
}
</style>
		<div id="welcome">
			<p style="clear: both" />
		</div>
		<h3>Dodaj nowy wydział</h3>
		<h:form id="addDepartmentForm">
			<h:messages globalOnly="false" showDetail="true"
				errorClass="messagesError" fatalClass="messagesFatal"
				infoClass="messagesInfo" warnClass="messagesWarn" />
			<table class="showTable">
				<tr>
					<td><label>Nazwa:</label></td>
					<td><p:inputText id="name" required="true"
							styleClass="login_input_long" label="Nazwa"
							requiredMessage="Nazwa jest wymagana."
							validatorMessage="Nazwa musi być dłuższa niż dwa znaki!."
							value="#{departmentMBean.actualDepartment.name}">
							<f:ajax event="blur" render="nameM" />
							<f:validateLength minimum="3" />
						</p:inputText> <h:message id="nameM" for="name" style="color:red"
							showDetail="true" showSummary="true" tooltip="true" /></td>
				</tr>
				<tr>
					<td><label>Opis:</label></td>
					<td><p:inputTextarea id="description" required="true"
							styleClass="login_input_long" label="Opis"
							requiredMessage="Opis jest wymagany."
							value="#{departmentMBean.actualDepartment.description}"
							validatorMessage="Opis musi być dłuższe niż 2 znaki!"
							autoResize="false">
							<f:ajax event="blur" render="descriptionM" />
							<f:validateLength minimum="3" />
						</p:inputTextarea> <h:message id="descriptionM" for="description" style="color:red"
							showDetail="true" showSummary="true" tooltip="true" /></td>
				</tr>
				<tr>
					<td><label style="height: 100px">Uczelnia:</label></td>
					<td><p:selectOneMenu value="#{departmentMBean.choosenId}"
							editable="false" requiredMessage="Musisz wybrać jedną szkołę."
							styleClass="login_input_long" id="selectSchool">
							<f:selectItems value="#{schoolMBean.schools}" var="school"
								itemLabel="#{school.name}" itemValue="#{school.idSchool}" />
						</p:selectOneMenu> <h:message id="selectSchoolM" for="selectSchool"
							style="color:red" showDetail="true" showSummary="true"
							tooltip="true" /></td>
				</tr>
			</table>
			<br />
			<p:commandButton id="saveNewDepartment" type="submit"
				action="#{departmentMBean.saveDepartment}" value="Dodaj" />
		</h:form>


		<div id="main_content"></div>

	</ui:define>
</ui:composition>